package com.example.myapplication.lol.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

import com.example.myapplication.lol.base.BaseVpAdapter;
import com.example.myapplication.lol.bean.TabBean;
import com.example.myapplication.lol.ui.PostFragment;
import com.example.myapplication.lol.ui.RecordFragment;

public class VpRecordFragmentAdapter extends BaseVpAdapter<TabBean> {

    private RecordFragment recordFragment = new RecordFragment();
    private PostFragment postFragment = new PostFragment();

    public VpRecordFragmentAdapter(@NonNull FragmentManager fm) {
        super(fm);
    }

    @Override
    protected Fragment createFragment(int position) {
        Fragment fragment = null;
        TabBean bean = getData(position);
        if (bean.getType() == TabBean.TYPE_ARTICLE){
            switch (position){
                case 0:
                    return recordFragment;
                case 1:
                    return postFragment;
            }
        }
        return fragment;
    }
    @Nullable
    @Override
    public CharSequence getPageTitle(int position) { return getData(position).getTitle(); }
}
